package com.yycwxt.modules.admin.express;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yycwxt.domain.Express;
import com.yycwxt.modules.admin.data_import.ImpFile;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface ExpressMapper extends BaseMapper<Express> {

//    @Select("""
//            SELECT id, zq, dp,
//            			sf_dds, sf_ygkdf,sf_sjkdf,
//            			jszc_dds,jszc_ygkdf,jszc_sjkdf,
//            			sbc_dds,sbc_ygkdf,sbc_sjkdf,
//            			hnc_dds,hnc_ygkdf,hnc_sjkdf,
//            			fscc_dds,fscc_ygkdf,fscc_sjkdf,
//            			jszec_dds,jszec_ygkdf,jszec_sjkdf,
//            			jszfhc_dds,jszfhc_ygkdf,jszfhc_sjkdf,
//            			dfc_dds,dfc_ygkdf,dfc_sjkdf,
//            			ztkdf,stkdf,ddshj,ygkdfhj,sjkdfhj
//            FROM exp_kdf
//            WHERE zq = #{zq}
//            """)
//    List<Express> select(String zq);

    //调用存储过程生成数据
//    @Select("call generateKDF(#{zq})")
//    void generateKDF(String zq);

    // 查询账期
    @Select("SELECT distinct account_date FROM core_flows")
    Object[] selectZq();

    //查询快递费表格数据
    @SelectProvider(type = ExpressSelectProvider.class, method = "sql4Kdf")
    List<Map<String, Object>> select(Map<String, Object> map);

    //下载源文件查询url
    @Select("SELECT name, url FROM imp_files WHERE remark like '%快递费%';")
    List<ImpFile> selectUrl();

    //上传快递费对账单
    @Select("call importKdfdzd(#{zq,mode=IN,jdbcType=INTEGER},#{kdgs,mode=IN,jdbcType=VARCHAR}," +
            "#{ydh,mode=IN,jdbcType=VARCHAR},#{jszl,mode=IN,jdbcType=DECIMAL},#{qz,mode=IN,jdbcType=INTEGER}," +
            "#{sfcs,mode=IN,jdbcType=VARCHAR},#{mdsf,mode=IN,jdbcType=VARCHAR},#{mdcs,mode=IN,jdbcType=VARCHAR},#{kdf,mode=IN,jdbcType=DECIMAL}" +
            ",#{dp,mode=IN,jdbcType=VARCHAR},#{fhsj,mode=IN,jdbcType=TIMESTAMP});")
    public void importKdfdzd(Integer zq, String kdgs,
                             String ydh, BigDecimal jszl, Integer qz,
                             String sfcs, String mdsf, String mdcs,
                             BigDecimal kdf, String dp, LocalDateTime fhsj);
}
